I'm removing the css file dynamically to change the theme in angular application.
Theme change will happen based on the routing, I am listen/subscribe the router events in a service. Inside constructor I am calling below function
public clearHeader() {
const headers = [].filter.call(document.getElementbyTagName('link'), (e1: any) => e1.rel ==='stylesheet');
headers.forEach((ele)=> { document.head.removechild(ele)
});
When I am spyOn clearHeader() method in jasmine unit testing, it is removing css files from the dom, so in the another test case when try to call the clearHeader() method I'm getting below error Uncaught NotFoundError: Failed to execute 'removeChild' on 'Node': The node to be removed is not a child of this node. which means the css files are removed, there are no css files so I want to know how to mock [].filter.call method in angular service spec file. so that test cases won't remove the css files from the DOM